package net.siufung.mybatis.properties;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 租户数据表过滤对象
 * @author 陈建峰
 * @since 2021/11/12 2:38 下午
 */
@Data
@ConfigurationProperties(prefix = MybatisProperties.TENANT_IGNORE_PREFIX)
public class MybatisProperties {

    public static final String TENANT_IGNORE_PREFIX = "mybatis";

    /**
     * 数据源类型
     */
    private String dbType;

    /**
     * 启用检查sql
     */
    private boolean illegalSqlEnable = false;

    /**
     * 乐观锁启用
     */
    private boolean optimisticLockerEnable = true;

    /**
     * 防止全表更新与删除
     */
    private boolean blockAttackEnable = true;

    /**
     * 启用数据权限
     */
    private boolean dataScopeEnable = false;

    /**
     * 租户相关设置
     */
    private TenantSettings tenant;

    @Data
    static public class TenantSettings implements Serializable {

        private static final long serialVersionUID = -8890969026027467939L;

        /**
         * 启用租户
         */
        private boolean enable = false;

        /**
         * 被过滤的数据库表集合
         */
        private List<String> excludeTables = new ArrayList<>();

    }
}
